package usecases

import (
	"fmt"

	"gitverse.ru/EYMikhievich/api-gigachat/internal/modules/clientGigaChat/domain"
)

type PRChecker struct {
	Client             domain.ChatClient
	ModelGigachat      string
	SystemRoleGigachat string
	Stream             bool
}

func NewPRChecker(client domain.ChatClient, model, systemRole string, stream bool) *PRChecker {
	return &PRChecker{
		Client:             client,
		ModelGigachat:      model,
		SystemRoleGigachat: systemRole,
		Stream:             stream,
	}
}

func (checker *PRChecker) CheckPR(prDescription string, stream chan string) error {
	request := domain.ChatRequest{
		Model: checker.ModelGigachat,
		Messages: []domain.Message{
			{Role: "system", Content: checker.SystemRoleGigachat},
			{Role: "user", Content: prDescription},
		},
		Temperature: 0.7,
		Stream:      checker.Stream,
	}

	err := checker.Client.ChatRequest(request, stream)
	if err != nil {
		return fmt.Errorf("Ошибка отправки запроса в чат: %v", err)
	}

	return nil
}
